package com.cloudfun.campusshare.repo;

import com.cloudfun.campusshare.common.constant.RoleType;
import com.cloudfun.campusshare.entity.RoleEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * Created by Huqin on 2019/12/23
 */
public interface RoleEntityRepo extends
        PagingAndSortingRepository<RoleEntity, String>,
        JpaSpecificationExecutor<RoleEntity> {

    @Query(value = "select * from role where type in(?1)",nativeQuery = true)
    List<RoleEntity> findAllByTypeIn(Set<String> types);

    List<RoleEntity> findAllByIdIn(Collection<String> ids);

    List<RoleEntity> findAllByType(String name);

    List<RoleEntity> findAllByTypeNotNull();

    RoleEntity findByNameAndAndMerchantId(String name,String merchantId);

    List<RoleEntity> findAllByEnable(Boolean enable);

    List<RoleEntity> findAllByIdInAndEnable(Collection<String> ids, Boolean enable);

    List<RoleEntity> findAllByCreatorId(String creatorId);

}
